<template>
  <Layout>
    <el-container class="console-container">
      <SubMenu 
        :base-path="'/console'" 
        :routes="sidebarRoutes" 
        :redirect-first="true"
      />
      
      <el-main class="main-content">
        <router-view />
      </el-main>
    </el-container>
  </Layout>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import Layout from '@/components/Layout.vue'
import SubMenu from '@/components/SubMenu.vue'

const router = useRouter()

// 从路由配置中提取控制台的子路由
const sidebarRoutes = computed(() => {
  const consoleRoute = router.options.routes.find(r => r.path === '/console')
  return (consoleRoute?.children || []).filter(route => route.meta?.menu)
})
</script>

<style scoped>
.console-container {
  height: 100%;
}

.main-content {
  padding: 0;
  height: 100%;
  overflow: auto;
}
</style>